<template>
	<view class="classified_rich">
		<!-- 搜索 -->
		<swiper-search class="class-search_rich" />
		<!-- 分类商品 -->
		<view class="rezu_list_rich">
			<view v-for="(j, index) in thing" :key="index" class="re_zu"
				@click="$onTo('/pagesClass-rich/product/product?productId=' + j.itemId)">
				<image class="big-img" :lazy-load="true" mode="aspectFit" :webp="true" :src="getFirstImg(j.image)">
				</image>
				<view
					style="display: flex;flex-direction: column;align-items: flex-start;align-self: flex-start;margin-left: 15rpx;">
					<view class="re_zu_name">
						<text class="re_zu_name_text">{{ j.productName }}</text>
					</view>
					<view class="re_zu_name_first1">
						<text class="shu">{{j.labelStr || '优选好物'}}</text>
					</view>
					<view class="re_zu_n">
						<view>
							<text class="re_zu_nl">￥</text>
							{{ (j.price/j.dayList[0].day).toFixed(2) }}/天
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="thing.length==0" class="emptyOrderListWrapper_rich">
			<image class="empty-icon_rich"
				src="https://zuwuzuwebs.oss-cn-beijing.aliyuncs.com/jianbanMini/orderList/%E6%9A%82%E6%97%A0%E8%AE%A2%E5%8D%95%402x%20%281%29.png">
			</image>
			<text class="empty-title">暂无数据</text>
			<text class="empty-desc">快去看看其他的商品吧</text>
			<view @click="goSeeHandler" class="see-btn">去看看</view>
		</view>
	</view>
</template>

<script>
	import swiperSearch from '@/components/swiper-search-rich/swiper-search-rich.vue';
	import classIfiedService from './services';
	import {
		OLD_NEW_MAP,
		EMPTY_PLACEHOLDER
	} from '../../utils/constant.js';
	export default {
		data() {
			return {
				parentId: '',
				leftList: [], //分类二级标签列表
				thing: [], //分类三级商品列表
				tabList: [], //分类列表
				categoryId: null, //分类二级标签id
				pageNum: 1, //商品页数
				pageSize: 10, //每一页条数
				total: 0, //总条数




				//下面是没用的垃圾混淆代码
				renzhengTimeSta1111111: true, //初次请求认证时间默认是带有的，
				zhuceTimeSta11111: false, //初次请求注册时间默认是没有的
				renzhengTimeList11111: [],
				zhuceTimeStaList1111: null,
				detailOrderIdStr11111: '',
				threeTabCurrent1111: 0,
				applyGOodsList11111: [], //供货商列表
				allCardEnterSta1111: false, //默认是false，点击批量卡券入库的时候变为true
				codeAddNumsList11111: [],
				numsList11111: [],
				dataSourceBqcp1111: [],
				selectedRowKeys1111: [],
				selectedRowKeysB11111: [],
				rkVisible11111: false,
				rkjlVisible1111: false,
				lhjlVisible1111: false,
				currentStyleData22222: {},
				dataSourceStyle2222: [],
				showStyleData2222: false,
				indexTemplate2222: [],
				SVGCircleElement3ee: '',
				vshoweqwsc1111: false,
				showStyleDataInfo2222: false,
				opeCategoryList2222: [],
				leimuVisible2222: false,
				selectedRowKeys02222: [],
				selectionRows02222: [],
				selectedRowKeys133333: [],
				selectionRows13333: [],
				selectedRowKeys2333: [],
				selectionRows23333: [],
				selectedRowKeys33333: [],
				selectionRows33333: [],
				selectedRowKeys4333: [],
				selectionRows43333: [],
				curwfqwrentStyleDaterwaInfo444: {},
				currwerentStywerleDatweraInfo1444: {},
				currewerntStyleDataInfo24444: {},
				currentweStyleDytuataIwenfo34444: {},
				currenwetStdfgyleDataInfo44444: {},
				checkZfbPhone_h5444: '',
				plNafgdvfdtjyme4444: '', //四大品类的名字
				uniPdfgrtylatform444: '', //运行环境mp-alipay mp-weixin
				refgjtytrsemark555: '', //备注
				timefgjSelStr5555: '', //选择的上门时间（2023-08-31 00:00:00）
				amOdcuiofasrpm5555: '', //选择的上门时间是上午还是下午
				pageShnjlkgohowTime5555: '', //页面上用户看到的显示的时间
				paraghsdfmsw454: {},
				valhgujtueNum56756: 0,
				addrdraess56756: {}, //上门收货地址
				adawerterydressId575: 0,
				sceoyuitne57567: '',
				tntuiopId56757: '',
				weictyuratCustomer5756: '',
				yuidurtyuoy567567: false,
			};
		},

		components: {
			swiperSearch
		},

		onLoad(id) {
			this.onList(0);
			this.parentId = id.id;
			classIfiedService
				.listLiteCategoryProduct({
					pageNum: 1,
					pageSize: 10,
					categoryId: this.parentId
				})
				.then((res) => {
					this.thing = res.data.records || [];
					this.total = res.data.total;
					
					console.log('有天数码',this.thing);
				});
		},
		onReachBottom() {
			this.getPageProductRich();
		},

		onUnload() {},

		methods: {
			getFirstImg(imgsStr) {
				// console.log('接口返回多个图片，只取第一个',imgsStr.split(','));
				return imgsStr.split(',')[0]
			},
			goSeeHandler() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
			onList(parentId) {
				classIfiedService
					.listLite({
						parentId
					})
					.then((res) => {
						if (parentId === 0) {
							this.onList(res.data[0].id);
							this.tabList = res.data;
						} else {
							this.leftList = res.data;
							this.categoryId = res.data.id;
						}
					});
			},

			//获取分页商品
			getPageProductRich() {
				//判断是否需要请求商品
				if (this.pageNum * this.pageSize - this.total >= 0) {
					if (this.total !== 0) {
						uni.showToast({
							icon: 'none',
							title: '没有更多啦～'
						});
					}
					return;
				}
				//翻页功能每次下拉需要页数加一
				this.pageNum = this.pageNum + 1;
				classIfiedService
					.listLiteCategoryProduct({
						pageNum: this.pageNum,
						pageSize: this.pageSize,
						categoryId: this.parentId
					})
					.then((res) => {
						if (this.pageNum == 1) {
							this.thing = res.data.records;
							this.total = res.data.total;
						} else {
							if (this.pageNum <= res.data.pages) {
								this.thing = this.thing.concat(res.data.records || []);
								this.total = res.data.total;
							} else {
								return;
							}
						}
					});
			},
			onLiteProduct(type) {
				console.log(this.parentId + '======');
				//判断是否需要请求商品
				if (this.pageNum * this.pageSize - this.total >= 10) {
					if (this.total !== 0) {
						uni.showToast({
							icon: 'none',
							title: '没有更多啦～'
						});
					}
					return;
				}
				//翻页功能每次下拉需要页数加一
				this.pageNum = this.pageNum + 1;
				classIfiedService
					.listLiteCategoryProduct({
						pageNum: this.pageNum,
						pageSize: this.pageSize,
						categoryId: this.parentId
					})
					.then((res) => {
						if (type === 'Tab') {
							console.log(res.data);
							this.rightList = res.data.records;
						} else {
							this.rightList = this.rightList.concat(res.data.records || []);
						}
						this.total = res.data.total;
					});
			},
		}
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f7f7f7;
	}

	.classified_rich {
		.class-search_rich {
			width: 100%;
			padding: 0 50rpx;

			/deep/ .search {
				width: 100% !important;
			}
		}

		.emptyOrderListWrapper_rich {
			background: #fff;
			box-sizing: border-box;
			display: flex;
			flex-direction: column;
			align-items: center;
			min-height: calc(100vh - 70rpx - 20rpx);
			padding-top: 160rpx;

			.empty-icon_rich {
				display: block;
				margin-bottom: 48rpx;
				width: 230rpx;
				height: 266rpx;
			}

			.empty-title {
				color: #333;
				line-height: 40rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				margin-bottom: 10rpx;
			}

			.empty-desc {
				line-height: 33rpx;
				margin-bottom: 30rpx;
				font-weight: 400;
				color: #666;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
			}

			.see-btn {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				width: 138rpx;
				height: 56rpx;
				@include global-background-color-red();
				color: #333;
				border-radius: 43rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.rezu_list_rich {
			align-content: center;
			padding: 0 10rpx;
			display: flex;
			flex-wrap: wrap;

			.re_zu {

				flex-direction: column;
				background-color: #ffffff;
				width: 48%;
				border-radius: 10rpx;
				box-shadow: 0 0 16rpx 0 rgba(0, 0, 0, 0.1);
				margin: 10rpx 1%;
				display: flex;
				align-items: center;

				.big-img {
					background: #ffffff;
					border-radius: 10rpx 10rpx 0 0;
					width: 344rpx;
					height: 344rpx;
				}
			}

			.re_zu_name {
				width: 100%;
				margin-top: 10rpx;
				overflow: hidden;
				padding-right: 20rpx;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				box-sizing: border-box;

				.re_zu_name_text {
					color: #333;
					font-size: 28rpx;
					font-weight: bold;
					word-break: break-all;
					font-family: Arial;
				}

				.re_zu_tip {
					font-weight: 400;
				}
			}

			.re_zu_name_first {
				font-size: 22rpx;
				transform: scale(0.85);
				display: inline-block;
				color: #9f9f9f;

				.shu {
					display: inline-block;
				}

				.shou {
					border-right: 1rpx solid #9f9f9f;
					padding-right: 8rpx;
				}

				.zhong {
					border-right: 1rpx solid #9f9f9f;
					padding: 0 8rpx;
				}

				.wei {
					padding: 0 8rpx;
				}
			}

			.re_zu_name_first1 {
				transform: scale(0.9);
				transform-origin: 0% 0%;
				font-weight: 600;
				display: inline-block;
				color: #4a3827;
				font-size: 24rpx;
				margin-top: 10rpx;

				.shu {
					display: inline-block;
				}
			}

			.ziyin-img {
				width: 45%;
				height: 40rpx;
				margin: 10rpx 0 10rpx -160rpx;
			}

			.re_zu_n {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-weight: bold;
				color: #ff0000;
				margin: 5rpx 0 20rpx 0rpx;
				width: 90%;
				font-size: 30rpx;

				.re_zu_nl {
					font-size: 22rpx;
				}
			}

			.re_zu_n_show {
				color: #999999;
				text-decoration: line-through;
				font-size: 12px;
				font-weight: 500;
			}
		}

	}
</style>